import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: '/',
            component: () => import('../views/home/Home.vue')
        },
        {
            path: '/home',
            component: () => import('../views/home/Home.vue')
        },
        {
            path: '/cart',
            component: () => import('../views/cart/Cart.vue'),
            meta: {
                isAuth: true
            }
        },
        {
            path: '/my',
            component: () => import('../views/my/My.vue'),
            meta: {
                isAuth: true
            }
        },
        {
            path: '/order',
            component: () => import('../views/order/Order.vue'),
            meta: {
                isAuth: true
            }
        },
        {
            path: '/login',
            component: () => import('../views/login/Login.vue'),
        },
        {
            path: '/register',
            component: () => import('../views/register/Register.vue'),
        },
        {
            path: '/address',
            component: () => import('../views/address/Address.vue'),
        },
        {
            path: '/userInfoEdit',
            component: () => import('../views/userInfoEdit/UserInfoEdit.vue'),
        },
        {
            path: '/addressEdit',
            component: () => import('../views/address/AddressEdit.vue'),
        }
        
    ]
})



// router.beforeEach((to, from, next) => {
//     if (to.meta.isAuth) {
//         if (localStorage.getItem('isLogin') == '1') {
//             next()
//         } else {
//             alert('请先登录')
//             router.push('./login')
//         }
//     } else {
//         next()
//     }
// })

export default router